package com.gome.ocean.service.utils;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

/**
 * @author zhangguoqing 2016年8月8日 下午3:10:56
 * @since 5.0.0
 */
@SuppressWarnings("resource")
public class HttpClientEsUtil {

    private static Client client;

    /**
     * client初始化
     */
    static{

        Settings settings = ImmutableSettings.builder()
                .put("cluster.name", "gome_app_cluster")
                .put("client.transport.sniff",true)
                .build();

        client = new TransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress("10.115.88.47", 9300))
                .addTransportAddress(new InetSocketTransportAddress("10.115.88.48",9300));
    }
    
    public static Client getClient(){
        return client;
    }
    
}
